<?php

namespace app\admin\model\partner\stone;

use think\Model;


class Log extends Model
{

    

    

    // 表名
    protected $name = 'partner_stone_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'stone_type_text'
    ];
    

    
    public function getTypeList()
    {
        return ['1' => __('Type 1'), '2' => __('Type 2')];
    }

    public function getStoneTypeList()
    {
        return ['1' => __('Stone_type 1'), '2' => __('Stone_type 2'), '3' => __('Stone_type 3')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStoneTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['stone_type']) ? $data['stone_type'] : '');
        $list = $this->getStoneTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function from()
    {
        return $this->belongsTo('\\app\\admin\\model\\User', 'from_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function to()
    {
        return $this->belongsTo('\\app\\admin\\model\\User', 'to_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}
